home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Tools / Dev_Libs / Amiblitz2 / thilo_includes / examples / dbl_benchmark.ab2 < prev    next >
Text File  |  2004-01-28  |  6KB  |  173 lines

  1. optimize 7
  2. Syntax 2
  3. WBStartup
  4. !tklibs_include
  5. ;!dbl_include
  6. ;!dbl_include   ;1,1 best For gfx card and if you want scrolling
  7. ;!dbl_include 0,0 ;best for AGA AND workbench games
  8.  
  9. #scrl     = 0    ; scroll background
  10. maxdepth.l = 1   ; max depth of screen
  11.  
  12. NEWTYPE.ball
  13. x.q
  14. y.q
  15. xs.q
  16. ys.q
  17. End NEWTYPE
  18.  
  19. Dim List ball.ball(0)
  20. ballcounter.l  = 0
  21. message.s      = ""
  22. succ.l         = False
  23. balltyp.l      = 3
  24. breakme.l      = False
  25. scrl.l         = False
  26. Statement newmessage {}
  27. SHARED ball(),ballcounter,message.s,balltyp,ballsize.l,ballshot.l
  28. Format ""
  29. If balltyp=2 Then a.s = "64x64"
  30. If balltyp=3 Then a.s = "32x32"
  31. If balltyp=4 Then a.s = "16x16"
  32. message.s = "balls: "+Str$(ballcounter)+" / size: "+a.s+" / fps: "
  33. Format "000.00"
  34. End Statement
  35.  
  36.  
  37.  
  38. Statement ball_add {}
  39. SHARED ball(),ballcounter,message.s,balltyp,width.l,height.l
  40. If AddItem(ball())
  41.   ball()\x=Rnd(width),Rnd(height),(Rnd-.5)*20+1,(Rnd-.5)*20+1
  42.   ballcounter+1
  43. End If
  44. newmessage {}
  45. End Statement
  46.  
  47. Statement ball_remove {}
  48. SHARED ball(),ballcounter,message.s,balltyp
  49. ResetList ball()
  50. If NextItem(ball())
  51.   KillItem ball():ballcounter-1
  52. End If
  53. newmessage {}
  54. End Statement
  55. .initall
  56. path.s = "/gfx/" ; set your path here, including "/" !
  57. !screen_ {0,"test","ram:test",3}
  58. width.l=!screen_width:height.l=!screen_height
  59.  ret.l=ahi_open {0}
  60.  ret=ret & ahi_loadsound {0,"/sfx/transform"}
  61. If  dbl_init {"MyGame",!screen_id,width,height,!screen_depth}
  62.  
  63.     dbl_showpointer{}
  64.   dbl_setpen {1,144,144,144}                  ; set pen 1 so that we can see error messages
  65.   If image_load {1,path.s+"pattern"}
  66.     dbl_bgblitpattern{1,0,0,width,height}   ; blit the background pattern in window
  67.     image_setdithermode {1,0}
  68.  
  69.     succ=image_load {2,path.s+"ball64x64",0}  ; set path above
  70.     succ&image_load {3,path.s+"ball32x32",0}
  71.     succ&image_load {4,path.s+"ball16x16",0}
  72.     image_midhandle {2}
  73.     image_midhandle {3}
  74.     image_midhandle {4}
  75.     If succ
  76.       count.l = 0
  77.       res.q   = 50
  78.      succ=vvblank_set {25}  ;set a maximum framerate of 25 fps
  79. .messageloop_start
  80.     While breakme=False
  81.         ;res=Timer:ResetTimer:If res=0 Then res=1 ;old Hardware way
  82.         res=eclock_stop{}:eclock_start{50}:If res=0 Then res=1 ;changes for new timer here
  83.         vvblank_reset_sync{}
  84.         ev.l = Event
  85.         While ev
  86.           If ev= #IDCMP_MOUSEBUTTONS
  87.                If EventCode=$68
  88.                     fireval.l+1
  89.                Else
  90.                     fireval=0
  91.                End If
  92.           End If
  93.           If ev= #IDCMP_VANILLAKEY
  94.                Select EventCode
  95.                  Case 27
  96.                    breakme = True
  97.                  Case 97
  98.                    ball_add{}
  99.                    Use Window 0
  100.                    WLocate 10,10
  101.                  Case 114
  102.                    ball_remove{}
  103.                  Case 115
  104.                    scrl=1-scrl
  105.                    sxv.q= Rnd*2 * Sgn(Rnd-.5):syv.q=Rnd*2 * Sgn(Rnd-.5)
  106.                  Case 99
  107.                    balltyp+1:If balltyp=5 Then balltyp=2
  108.                    newmessage {}
  109.                  Case 109
  110.                    If imagedat(2)\mask_ptr
  111.                      FreeMem_ imagedat(2)\mask_ptr,0 : imagedat(2)\mask_ptr = False
  112.                      FreeMem_ imagedat(3)\mask_ptr,0  : imagedat(3)\mask_ptr = False
  113.                      FreeMem_ imagedat(4)\mask_ptr,0  : imagedat(4)\mask_ptr = False
  114.                    Else
  115.                      image_initmask{2,0}
  116.                      image_initmask{3,0}
  117.                      image_initmask{4,0}
  118.                    End If
  119.                 End Select
  120.             End If
  121.           ev=Event
  122.         Wend
  123.  
  124.         If scrl
  125.           scroll_x.l - sxv.q
  126.           scroll_y.l - syv.q
  127.           dbl_bgscroll{sxv.q,syv.q}
  128.           If sxv<0
  129.             dbl_bgblitpattern{1,0,0,-sxv,height,scroll_x,scroll_y}
  130.           Else
  131.             dbl_bgblitpattern{1,width-1-sxv,0,sxv,height,scroll_x,scroll_y}
  132.           End If
  133.            If syv<0
  134.             dbl_bgblitpattern{1,0,0,width,-syv,scroll_x,scroll_y}
  135.           Else
  136.             dbl_bgblitpattern{1,0,height-1-syv,width,syv,scroll_x,scroll_y}
  137.           End If
  138.         End If
  139.         dbl_flip{}           ; flip the doublebuffer !
  140.         dbl_unqueue{}        ; unblit all objects drawn with "dbl_q???" commands
  141.         ResetList ball()
  142.              ;If Joyb(0)=1 Then fireval.l+1:Else fireval=0
  143.         While NextItem(ball())
  144.          If   dbl_2imghit {balltyp,ball()\x,ball()\y,@@
  145.                -1,SMouseX,SMouseY}@@  ;@@ mean join next line to term
  146.                AND (fireval > 0 AND fireval < 2);last value increase for MG depend on magazine size
  147.                KillItem ball():ballcounter-1
  148.                ballshot+1
  149.                ahi_playsound {0}
  150.           Else
  151.                ball()\x+ball()\xs*correctspeed.l
  152.                ball()\y+ball()\ys*correctspeed
  153.                If ball()\x<0 OR ball()\x>width  Then ball()\xs=-ball()\xs
  154.                If ball()\y<0 OR ball()\y>height Then ball()\ys=-ball()\ys
  155.                dbl_qblit {balltyp,ball()\x,ball()\y}     ;draw balls
  156.             End If
  157.         Wend
  158.         dbl_qprint {message.s+Str$(50/res)+" Score "+Str$(ballshot),10,10,2}  ; Print a text for 1 frame
  159.         ;dbl_qprint {message.s+Str$(1000/res),10,10,2}  ; Print a text for 1 frame
  160.         dbl_qprint {"ESC=exit  (a)dd ball (r)emove ball  (c)hange Type  (m)ask Toggle (s)croll LMB=Remove Ball",10,height-16,2}
  161.  
  162.         ;loop       If eclock_stop{}<1 Then Goto loop ;need for framerate limit
  163.                    correctspeed.l=1;eclock_start{}      ;need for same speed regardless on framerate
  164.        vvblank_wait_sync{1}
  165.        Wend
  166.     End If
  167.   End If
  168. End If
  169. End
  170.  
  171.  
  172.  
  173.